﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;
using WebProjectOrder.BusinessLayer;

namespace WebProjectOrder.WebServices
{
    public class WebServices
    {
        //TODOS LOD DATOS DE ESTA CLASE SOLO ESTAN ALAMBRADOS
        #region Singleton
        private WebServices() 
        {
        }
        
        // Unica instancia de esta clase
        private static WebServices _instance;
        /// <Summary>
        /// Método para implementar el patrón Singleton
        /// </Summary>
        /// <returns>Instancia única de la clase </returns>
        public static WebServices getInstance() 
        {
            if (_instance == null)
                _instance = new WebServices();
            return _instance;
        }

        #endregion

        #region Métodos Públicos

        ///<Summary>
        ///Método que retorna una tabla hash 
        ///</Summary>
        ///<returns>Retorna una Tabla Hash con todas las Cuentas Auxiliares</returns>
        public Hashtable getAuxAccount() 
        {
            List<AuxiliarAccount> listAuxAccount = new List<AuxiliarAccount>();
            AuxiliarAccount newAuxAccount = new AuxiliarAccount();
            Hashtable hashResult = new Hashtable();
            Currency newCurrency = new Currency("E","Euros", 1, 2.3, Constants.CurrencyType.local, "Prueba");

            newAuxAccount.AccountID = 1;
            newAuxAccount.Name = "Cuenta Aux 1";
            newAuxAccount.OwnerName = "Karol Hernández";
            newAuxAccount.AccountCode = "C001";
            newAuxAccount.AccountType = Constants.AuxiliarAccountType.client;
            newAuxAccount.EntryType = Constants.AuxiliarEntryType.person;
            newAuxAccount.AccountCurrency = newCurrency;
            newAuxAccount.Amount = 10;
            newAuxAccount.LimitedCreditAmount = 20;
            newAuxAccount.Parent = 1;
            newAuxAccount.PayCondition = "Condicion 1";
            newAuxAccount.AlDebe = true;
            newAuxAccount.Contrasena = "12345";

            hashResult.Add(newAuxAccount.AccountID, newAuxAccount);

            return hashResult;
        }
        
        /// <summary>
        /// Método que me da todas las modenas que existen en el sistema
        /// </summary>
        /// <returns>
        /// Lista de todas las monedas 
        /// </returns>
        public List<Currency> getCurrencies() 
        {
            List<Currency> listCurrencies = new List<Currency>();
            Currency currency1 = new Currency("$", "&&", 1, 2.3, Constants.CurrencyType.added, "Dolares");
            Currency currency2 = new Currency("¢", "&&", 2, 2.3, Constants.CurrencyType.added, "Colones");
            Currency currency3 = new Currency("E", "&&", 3, 2.3, Constants.CurrencyType.added, "Euros");
            Currency currency4 = new Currency("¢", "&&", 4, 2.3, Constants.CurrencyType.local, "Colones");
            Currency currency5 = new Currency("¢", "&&", 5, 2.3, Constants.CurrencyType.system, "Colones");
            listCurrencies.Add(currency1);
            listCurrencies.Add(currency2);
            listCurrencies.Add(currency3);
            listCurrencies.Add(currency4);
            listCurrencies.Add(currency5);
            return listCurrencies;
        }


        /// <summary>
        /// Método que se encarga de dar todas las bodegas que existen en el inventario
        /// </summary>
        /// <returns>
        /// Lista de todas las bodegas
        /// </returns>
        public List<StoreRoom> getStoreRooms() 
        {
            List<StoreRoom> StoreRoomList = new List<StoreRoom>();
            Account newAccount =  new Account();
            newAccount.AccountID = 1;
            newAccount.Name = "Cuenta";
            newAccount.ForeignName = "Cuentaaa";
            newAccount.AccountCode = "C001";
            newAccount.AccountType = Constants.AccountType.active;
            newAccount.SpecialType = Constants.SpecialType.dividends;
            newAccount.IsTitle = true;
            newAccount.AlDebe = false;
            newAccount.AccountCurrency = new Currency("E", "&&", 1, 2.3, Constants.CurrencyType.local, "Euros");
            newAccount.LocalAmount = 2500;
            newAccount.SysAmount = 5000;
            newAccount.Parent = newAccount;
            StoreRoom newStoreRoom1 = new StoreRoom(1, "B1", "Bodega1", newAccount, newAccount, newAccount, newAccount );
            StoreRoom newStoreRoom2 = new StoreRoom(2, "B2", "Bodega2", newAccount, newAccount, newAccount, newAccount);
            StoreRoom newStoreRoom3 = new StoreRoom(3, "B3", "Bodega3", newAccount, newAccount, newAccount, newAccount);
            StoreRoom newStoreRoom4 = new StoreRoom(4, "B4", "Bodega4", newAccount, newAccount, newAccount, newAccount);
            StoreRoom newStoreRoom5 = new StoreRoom(5, "B5", "Bodega5", newAccount, newAccount, newAccount, newAccount);

            StoreRoomList.Add(newStoreRoom1);
            StoreRoomList.Add(newStoreRoom2);
            StoreRoomList.Add(newStoreRoom3);
            StoreRoomList.Add(newStoreRoom4);
            StoreRoomList.Add(newStoreRoom5);
            return StoreRoomList;
        }

        /// <summary>
        /// Método que obtiene toda la info de los impuestos
        /// </summary>
        /// <returns></returns>
        public List<Tax> GetTaxes() 
        {
            List<Tax> taxList = new List<Tax>();
            Tax newTax1 = new Tax(1, "Impuesto1", "I1", 2);
            Tax newTax2 = new Tax(2, "Impuesto2", "I2", 28);
            Tax newTax3 = new Tax(3, "Impuesto3", "I3", 1);
            Tax newTax4 = new Tax(4, "Impuesto4", "I4", 8);
            Tax newTax5 = new Tax(5, "Impuesto5", "I5", 9);

            taxList.Add(newTax1);
            taxList.Add(newTax2);
            taxList.Add(newTax3);
            taxList.Add(newTax4);
            taxList.Add(newTax5);

            return taxList;
        }

        /// <summary>
        /// Método que se encarga de obtener todos los articulos registrados en la base de datos
        /// HAY UN SP PARA ESTO
        /// </summary>
        /// <returns> Una lista de objetos articulos</returns>
        public List<StoreItem> GetStoreItem(int idStore) 
        {
            List<StoreItem> StoreList = new List<StoreItem>();
            // stock, comprometido, solicitado, costo
            StoreItem newStoreItem1 = new StoreItem(1,1,1,1,1,1,34,45,12,456, "articulo1", "Um1", "buen Articulo", "A001");
            StoreItem newStoreItem2 = new StoreItem(1, 3, 1, 1, 1, 1, 12, 32, 1, 563, "articulo3", "Um3", "buen Articulo", "A003");
            StoreItem newStoreItem3 = new StoreItem(2, 3, 1, 1, 1, 1, 0, 32, 1, 563, "articulo3", "Um3", "buen Articulo", "A003");
            StoreItem newStoreItem4 = new StoreItem(2, 4, 1, 1, 1, 1, 14, 32, 1, 2875, "articulo4", "Um4", "buen Articulo", "A004");
            StoreItem newStoreItem5 = new StoreItem(2, 5, 1, 1, 1, 1, 10, 32, 1, 938, "articulo5", "Um5", "buen Articulo", "A005");
            StoreItem newStoreItem6 = new StoreItem(3, 6, 1, 1, 1, 1, 8, 32, 1, 284, "articulo6", "Um6", "buen Articulo", "A006");
            StoreItem newStoreItem7 = new StoreItem(4, 3, 1, 1, 1, 1, 23, 32, 1, 852, "articulo3", "Um3", "buen Articulo", "A003");
            StoreItem newStoreItem8 = new StoreItem(4, 2, 1, 1, 1, 1, 8, 32, 1, 468, "articulo2", "Um2", "buen Articulo", "A002");
            StoreItem newStoreItem9 = new StoreItem(5, 3, 1, 1, 1, 1, 2, 32, 1, 789, "articulo3", "Um3", "buen Articulo", "A003");
            StoreItem newStoreItem10 = new StoreItem(3, 1, 1, 1, 1, 1, 9, 32, 1, 456, "articulo1", "Um1", "buen Articulo", "A001");
            StoreItem newStoreItem11 = new StoreItem(5, 2, 1, 1, 1, 1, 12, 32, 1, 123, "articulo2", "Um2", "buen Articulo", "A002");

            StoreList.Add(newStoreItem1); StoreList.Add(newStoreItem2); StoreList.Add(newStoreItem3);
            StoreList.Add(newStoreItem4); StoreList.Add(newStoreItem5); StoreList.Add(newStoreItem6);
            StoreList.Add(newStoreItem7); StoreList.Add(newStoreItem8); StoreList.Add(newStoreItem9);
            StoreList.Add(newStoreItem10); StoreList.Add(newStoreItem11);
            List<StoreItem> newStore = new List<StoreItem>();
            foreach (StoreItem storeItem in StoreList) 
            {
                if (storeItem.IdBodega == idStore)
                {
                    newStore.Add(storeItem);
                }
                else { }
            }
            return newStore;
        }


        #endregion

    }
}